<template>
  <div>
    <!-- <Header :contentTitle="headerTitle"></Header> -->
		<h2 class="hh2">{{headerTitle}}</h2>
    <div class="raterList">
      <Rater 
        v-for="(item, index) of sendLists" 
        :key="index" 
        :raterTitle="item" 
        :raterSort="index + 1" 
        :isRateShow="false" 
        :raterCurrent="0" 
        @sort="getSort">
      </Rater>

    </div>
    <div class="footer">
      <button @click="submitScore">确认提交</button>
    </div>
    <div style="width: 7.5rem;height: 2.5rem;"></div>
  </div>
</template>

<script>
  import Header from '~/components/Header'
  import Rater from '~/components/Rater'
	import axios1 from '~/plugins/axios1';
	import ls from 'store2'
  export default {
    name: 'raterList',
    components: {
      Rater,
      Header
    },
    props: {
      headerTitle: {
        type: String,
        default: ''
      },
      sendLists: {
        type: Array,
        default: null,
      }
    },
		created() {
			this.types = this.$route.query.type * 1;
		},
    watch: {
      headerTitle(string) {

      },
      sendLists(arr) {

      }
    },
    data() {
      return {
        rate_1: 8,
        rate_2: 8,
        rate_3: 8,
        rate_4: 8,
        rate_5: 8,
        rate_6: 8,
      }
    },
    methods: {
      getSort(data) {
        if (data.No == 1) {
          this.rate_1 = data.sort;
        } else if (data.No == 2) {
          this.rate_2 = data.sort;
        } else if (data.No == 3) {
          this.rate_3 = data.sort;
        } else if (data.No == 4) {
          this.rate_4 = data.sort;
        } else if (data.No == 5) {
          this.rate_5 = data.sort;
        } else {
          this.rate_6 = data.sort;
        }
				
				
				
      },
			saveSingle(data) {
				let obs = {
					userType:ls.get('userType'),
					type:1,
					classify:this.types,
					parameter:data
				}
				axios1.post('/curricula/saveSingle',obs,true).then(res => {
					if (res.code === '0') {
						this.$vux.toast.text(res.message);
						setTimeout(()=>{
							this.commonJs.gosto('advantageTest')
						},20)
					}
				}).catch((error) => {
					this.$vux.toast.text(error);
				})
			},
      submitScore() {
        const params = {
          "rate1": this.rate_1,
          "rate2": this.rate_2,
          "rate3": this.rate_3,
          "rate4": this.rate_4,
          "rate5": this.rate_5,
          "rate6": this.rate_6,
        };
				console.log('paramsssss2ww',params)
				if(this.rate_1==8 || this.rate_2==8 || this.rate_3==8 || this.rate_4==8 || this.rate_5==8 || this.rate_6==8){
					this.$vux.toast.text('您有科目没有打分,请打分后提交');
					return false;
				}
				let paramss = JSON.stringify(params)
				this.saveSingle(paramss)
        console.log('params', paramss);
      }
    }
  }
</script>

<style lang="less" scoped>
// 		/deep/.header{
// 			text-align: right;
// 		}
			.hh2{
					font-size:0.44rem;
					font-weight:bold;
					color:rgba(34,34,34,1);
					line-height:0.44rem;
					text-align: left;
					padding: 0 0.3rem;
					box-sizing: border-box;
			}
    .footer {
      margin-top: 0.9rem;
      text-align: center;
      button {
        width: 5rem;
        height: 0.7rem;
        outline: none;
        border: none;
        border-radius: 2.5rem;
        background: #6CBF20;
        color: #FFF;
        font-size: 0.3rem;
        letter-spacing: 0.1rem;

      }
    }
</style>

